#include "hiVideoImage.h"
#include "ffmpegThreadProxy.h"
#include "videoOption.h"
#include "videoThreadProxy.h"

HiVideo2Image::HiVideo2Image()
    : video_option(new VideoOption()), ffmpeg_thread(new FfmpegThreadProxy()),
      video_thread(new VideoThreadProxy()) {}

HiVideo2Image::~HiVideo2Image() {
    delete ffmpeg_thread;
    ffmpeg_thread = nullptr;
    delete video_thread;
    video_thread = nullptr;
}

bool HiVideo2Image::start(const char *rtsp_url, uint16_t port, uint32_t width,
                          uint32_t height, long flag) {
    this->video_option->init(rtsp_url, port, width, height, flag);

    ffmpeg_thread->start(*this->video_option);
    video_thread->start(*this->video_option);
    return true;
}

void HiVideo2Image::stop() {
    ffmpeg_thread->stop();
    video_thread->stop();
}
